package com.wd.live.base.util

import com.tencent.mmkv.MMKV


/**
 * 时间:2023/12/12
 * 作者:程志昂
 * 功能:临时存储用户信息
 */
object InfoUtil {
    //模拟器的账号
//     var userId: Int = 3587
//     var sessionId: String? = "17035017651023587"

//    var userId: Int = MMKVUtil.getMMkv().getInt("userId", 0)
//    var sessionId: String? = MMKVUtil.getMMkv().getString("sessionId", "")

    var appId: String = "e394d3be4df34e1d9f8b67bc5a007de7"

    fun setBasicId(userId: Int, sessionId: String) {
        val kv = MMKV.defaultMMKV()
        kv.encode("userId", userId)
        kv.encode("sessionId", sessionId)
    }
     fun serIsLogin(isLogin: Boolean){
          val kv=MMKV.defaultMMKV()
          kv.encode("isLogin",isLogin)
     }

    /**
     * 获取UserId
     */
    @JvmStatic
    fun getUserId(): Int {
        val kv = MMKV.defaultMMKV()
        return kv.decodeInt("userId")
    }

    /**
     * 获取SessionId
     */
    @JvmStatic
    fun getSessionId(): String? {
        val kv = MMKV.defaultMMKV()
        return kv.decodeString("sessionId")
    }

    @JvmStatic
    fun getIsLogin(): Boolean {
        val kv = MMKV.defaultMMKV()
        return kv.decodeBool("isLogin")
    }


}